/**
* @mxmlc -output=bin/assets/modules/begin.swf -external-library-path+=lib/library.swc -debug=false -noplay
*/
package begin 
{
	import begin.view.ChooseMonarch;
	import begin.view.EnterGame;
	import org.airmvc.View;
	
	/**
	 * 
	 * @author WLDragon 2014-02-28
	 */
	public class BeginV extends View 
	{
		
		public function BeginV(){}
		
		override public function init():void 
		{			
			Lyr.setBackGround(0x000000);
			enterGame = new EnterGame();
			addChild(enterGame);
			enterGame.play();
		}
		
		override protected function addListeners():void 
		{
			receive(BeginC.SHOW_OR_HIDE,handleShowOrHide);
			receive(BeginC.OPEN_SECOND_MENU,enterGame.openSecondMenu);
			receive(BeginC.ENTER_MONARCH, handleChooseMonarch);
		}
		
		private function handleChooseMonarch():void 
		{
			removeChild(enterGame);
			Lyr.setBackGround(0xFFC8B9);
			
			graphics.clear();
			chooseMonarch = new ChooseMonarch();
			addChild(chooseMonarch);
			chooseMonarch.index = 0;
		}

		private function handleShowOrHide():void 
		{
			if (parent) 
			{
				Lyr.ui.removeChild(this);
			}
			else 
			{
				Lyr.ui.addChild(this);
			}
		}
		
		private var enterGame:EnterGame;
		private var chooseMonarch:ChooseMonarch;
	}
	
}